package com.sikaryofficial.common.core.utils;

import cn.hutool.extra.spring.SpringUtil;

public class FileUrlUtils {

    /**
     * 获取HiSMKDig文件访问地址
     * @param url
     * @return
     */
    public static String getHiSMKDigFileUrl(String url) {
        if (url == null || url.isEmpty()) {
            return null;
        }
        String property = SpringUtil.getProperty("server-url.hismk-dig-obs");
        if (property == null) {
            return url;
        }
        if (!property.endsWith("/")) {
            property += "/";
        }
        // 如果是http开头，则直接返回
        if (url.startsWith("http")) {
            return url;
        }
        if (url.startsWith("/")) {
            url = url.substring(1);
        }
        return property + url;
    }
}
